<app-page-header [pageHeaderInfo]="pageHeaderInfo"></app-page-header>
<div class="normal-table-wrap bg-color-no p-b-50">
  <form nz-form [formGroup]="validateForm">

    <nz-card [nzBordered]="false" nzTitle="组卷信息">
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>难度等级</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <nz-select formControlName="difficultyGrade" nzPlaceHolder="选择难度等级" nzAllowClear>
            <nz-option *ngFor="let item of difficultyOptions" [nzValue]="item.value"
                       [nzLabel]="item.label"></nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>单选分数</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
          <nz-input-number formControlName="radioScore" [nzMin]="0"
                           (ngModelChange)="sumScore()"></nz-input-number>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>多选分数</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
          <nz-input-number formControlName="multiScore" [nzMin]="0"
                           (ngModelChange)="sumScore()"></nz-input-number>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>判断分数</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
          <nz-input-number nz-input formControlName="judgeScore" [nzMin]="0"
                           (ngModelChange)="sumScore()"></nz-input-number>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>漏选分数</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
          <nz-input-number nz-input formControlName="omitScore" [nzMin]="0"></nz-input-number>
        </nz-form-control>
      </nz-form-item>
    </nz-card>

    <nz-card [nzBordered]="false">
      <nz-form-item>
        <nz-form-control [nzSm]="4" [nzXs]="18">
          <button nz-button nzType="primary" class="add-button" (click)="add()">
            <i nz-icon nzType="plus"></i>
            新增题库
          </button>
        </nz-form-control>
      </nz-form-item>
      <nz-table [nzFrontPagination]="false" [nzBordered]="true"
                formArrayName="questionTestBankVos"
                [nzData]="items.value">
        <thead>
        <tr>
          <th nzWidth="30">题库</th>
          <th nzWidth="15">单选数量</th>
          <th nzWidth="15">多选数量</th>
          <th nzWidth="15">判断数量</th>
          <th nzWidth="10" [nzAlign]="'center'">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let item of items.controls; let i = index;" [formGroupName]="i">
          <td [nzAlign]="'center'">
            <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
              <nz-select formControlName="questionBankId" nzAllowClear style="width: 220px;">
                <nz-option *ngFor="let item of listExamOption" [nzValue]="item.value"
                           [nzLabel]="item.label"></nz-option>
              </nz-select>
            </nz-form-control>
          </td>
          <td>
            <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
              <nz-input-number formControlName="radioNum" [nzMin]="0"
                               (ngModelChange)="sumNumber($event,i,'radioNum')"></nz-input-number>
            </nz-form-control>
          </td>
          <td>
            <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
              <nz-input-number formControlName="multiNum" [nzMin]="0"
                               (ngModelChange)="sumNumber($event,i,'multiNum')"></nz-input-number>
            </nz-form-control>
          </td>
          <td>
            <nz-form-control [nzSm]="12" [nzXs]="18" [nzErrorTip]="combineTpl">
              <nz-input-number formControlName="judgeNum" [nzMin]="0"
                               (ngModelChange)="sumNumber($event,i,'judgeNum')"></nz-input-number>
            </nz-form-control>
          </td>
          <td align="center"><i nz-icon nzType="delete" nzTheme="outline" (click)="del(i)"></i></td>
        </tr>
        </tbody>
      </nz-table>

    </nz-card>
    <nz-card [nzBordered]="false" nzTitle="考试配置参数">
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>考试名称</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <input nz-input formControlName="name"/>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>考试描述</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <input nz-input formControlName="remark"/>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>总分</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <nz-input-number formControlName="countScore" [nzPrecision]="1" [nzDisabled]="true"></nz-input-number>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>及格分</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <nz-input-number formControlName="passScore" [nzMin]="0" [nzPrecision]="1"></nz-input-number>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>考试时长(分钟)</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5" [nzErrorTip]="combineTpl">
          <nz-input-number formControlName="duration" [nzMin]="0"></nz-input-number>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="4" [nzXs]="18" nzRequired>是否限时</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5">
          <label nz-checkbox formControlName="timeLimitFlag" (ngModelChange)="show($event)"></label>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item *ngIf="isDisplay">
        <nz-form-label [nzSm]="4" [nzXs]="18">考试时间</nz-form-label>
        <nz-form-control [nzSm]="12" [nzXs]="18" [nzXl]="5" [nzXXl]="5">
          <nz-range-picker formControlName="createTime" nzShowTime></nz-range-picker>
        </nz-form-control>
      </nz-form-item>
    </nz-card>
  </form>


</div>

<app-footer-submit>
  <button nz-button type="primary" nzType="primary" (click)="submit()">保存</button>
  <button nz-button type="default" (click)="returnToList()" class="m-l-15">返回</button>
</app-footer-submit>

<ng-template #combineTpl let-control>
  <ng-container *ngIf="control.hasError('message')">{{control.errors.message}}</ng-container>
  <ng-container *ngIf="control.hasError('required')">必填项</ng-container>
</ng-template>

